// 红灯3秒亮一次，黄灯2秒亮一次，绿灯1秒亮一次；如何让三个灯不断交替重复亮灯？

function red() {
  console.log("red");
}
function green() {
  console.log("green");
}
function yellow() {
  console.log("yellow");
}

function light() {
  new Promise((r) => {
    setTimeout(() => r(red()), 3000);
  })
    .then((r) => {
      return new Promise((r) => {
        setTimeout(() => r(yellow()), 2000);
      });
    })
    .then((r) => {
      return new Promise((r) => {
        setTimeout(() => r(green()), 1000);
      });
    }).then(()=>{
        return light()
    });
}

light();
